package timing.jframe4l.note;

/**
 * Description:
 * <br>网站：<a href="http://www.gitee.com/fengxici">Fengxici</a>
 * <br>Copyright (c),2017,Fengxici
 * <br>This program is protected by copyright laws.
 * <br>Program Name:FlowControlDemo
 * <br>Date:2018/1/3
 *
 * @author Fengxici
 * @version 1.0
 * Created by Fengxici on 2018/1/3.
 */
public class FlowControlDemo {

    /**
     * 程序入口
     *
     * @param args 入口接收函数
     */
    public static void main(String[] args) {
        //年龄
        int age = 30;
        /////////////////////if control//////////////////////////
        if (age > 20) {
            System.out.println("青年人");
        } else if (age > 40) {
            System.out.println("中年人");
        } else if (age > 60) {
            System.out.println("老年人");
        }
        //=====================switch control==============================
        //数据类型只能是byte、short、char和int，Java7 新增枚举类型和String类型支持
        char score = 'C';
        switch (score) {
            case 'A':
                System.out.println("优秀");
                break;
            case 'B':
                System.out.println("良好");
                break;
            case 'C':
                System.out.println("中");
                break;
            case 'D':
                System.out.println("及格");
                break;
            case 'E':
                System.out.println("不及格");
                break;
            default:
                System.out.println("成绩录入有误");
        }
        String season = "春天";
        switch (season) {
            case "春天":
                System.out.println("春暖花开！");
                break;
            case "夏天":
                System.out.println("夏日炎炎！");
                break;
            case "秋天":
                System.out.println("秋高气爽！");
                break;
            case "冬天":
                System.out.println("冬雪皑皑！");
                break;
            default:
                System.out.println("季节有误！");
        }

        //////////////////////////while control//////////////////////////////
        int count = 0;
        while (count < 10) {
            count++;
            System.out.println(count);
        }
        System.out.println("while循环结束了");
        //========================do while control=============================
        count = 0;
        do {
            count++;
            System.out.println(count);
        } while (count < 10);
        System.out.println("do while循环结束了");
        ////////////////////////for control/////////////////////////////////////
        for (int i = 1; i < 10; i++) {
            System.out.println(i * 10);
            int mod = i * 3 % 5;
            if (mod != 0)
                continue;
            else
                break;
        }
        System.out.println("for循环结束了");
        //=====================嵌套循环=========================================
        outer:
        for (int i = 1; i < 10; i++) {
            inner:
            for (int j = 1; j < 10; j++) {
                System.out.println("嵌套循环" + i * j);
                int mod = i * j % 5;
                if (mod == 1) {
                    continue outer;
                } else if (mod == 0) {
                    break inner;
                } else if (mod == 3) {
                    return;
                }
            }
        }
    }
}
